/**
 * Created by IntelliJ
 * Author:熊磊
 */
public class HanoTower {
    static long n = 0;

    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        hanoTower(23);
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }

    public static void hanoTower(int num) {
        hanoTower(num, 'A', 'B', 'C');
        System.out.println("一共需" + n + "步完成" + num + "个汉诺塔");
    }

    public static void hanoTower(int num, char a, char b, char c) {
        if (num == 1) {
            System.out.println("第1个盘从" + a + "->" + c);
            n++;
        } else {
            //先把上面的盘移到B
            hanoTower(num - 1, a, c, b);
            //把最后一个盘移动到C
            System.out.println("第" + num + "个盘从" + a + "->" + c);
            n++;
            //把B移动到C
            hanoTower(num - 1, b, a, c);
        }


    }
}
